package com.yitiao.controller;

import com.yitiao.service.IOrderTCCService;
import com.yitiao.service.impl.OrderServiceImpl;
import com.yitiao.service.impl.OrderTCCServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("orders")
@RequiredArgsConstructor
public class OrderController {

    private final OrderTCCServiceImpl orderTCCService;

    private final OrderServiceImpl orderService;

    @GetMapping(value = "/create")
    public String create(String userId, String commodityCode, int orderCount) {
        try {
//            orderTCCService.tryCreate(userId, commodityCode, orderCount);
            orderService.create(userId, commodityCode, orderCount);
        } catch (Exception exx) {
            exx.printStackTrace();
            return "FAIL";
        }
        return "SUCCESS";
    }
}
